<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>正方体</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh; /* 垂直居中 */
            background-color: #f0f0f0; /* 背景颜色 */
            perspective: 800px; /* 透视效果 */
            margin: 0;
        }

        .cube {
            position: relative;
            width: 200px;
            height: 200px;
            transform-style: preserve-3d;
            transform: rotateX(30deg) rotateY(-45deg);
        }

        /* 每个面样式 */
        .face {
            position: absolute;
            width: 200px;
            height: 200px;
            background-color: rgba(255, 255, 255, 0.8);
            border: 2px solid rgba(0, 0, 0, 0.5); /* 实线边框 */
        }

        /* 正方体的每个面颜色及位置 */
        .z1 {
            transform: rotateY(0deg) translateZ(100px);
            background-color: rgba(169, 54, 136, 0.8);
        }

        .z2 {
            transform: rotateY(90deg) translateZ(100px);
            background-color: rgba(42, 169, 51, 0.8);
        }

        .z3 {
            transform: rotateY(180deg) translateZ(100px);
            background-color: rgba(54, 73, 169, 0.8);
        }

        .z4 {
            transform: rotateY(-90deg) translateZ(100px);
            background-color: rgba(255, 204, 0, 0.8);
        }

        .z5 {
            transform: rotateX(90deg) translateZ(100px);
            background-color: rgba(255, 51, 51, 0.8);
        }

        .z6 {
            transform: rotateX(-90deg) translateZ(100px);
            background-color: rgba(255, 102, 102, 0.8);
        }

        /* 添加内部虚线框表示不可见的边 */
        .cube::before, .cube::after {
            content: "";
            position: absolute;
            width: 200px;
            height: 200px;
            border: 2px dashed rgba(0, 0, 0, 0.3); /* 虚线边框 */
            top: 0;
            left: 0;
            transform-origin: center;
        }

        .cube::before {
            transform: rotateY(45deg) rotateX(45deg) translateZ(100px); /* 虚线表示立方体内部的不可见边 */
        }

        .cube::after {
            transform: rotateY(-45deg) rotateX(-45deg) translateZ(-100px); /* 虚线表示立方体内部的不可见边 */
        }
    </style>
</head>

<body>
    <div class="cube">
        <div class="face z1"></div>
        <div class="face z2"></div>
        <div class="face z3"></div>
        <div class="face z4"></div>
        <div class="face z5"></div>
        <div class="face z6"></div>
    </div>
</body>
</html>
